/* epoch.c */

#include "epoch.h"

struct epoch_ty epoch(DWORD TimeDateStamp) {

   struct epoch_ty epoch_ty_instance;
         
   DWORD days = TimeDateStamp/(60*60*24);
   DWORD a_partial_day_in_seconds = TimeDateStamp%(60*60*24);
   DWORD a_partial_day_in_hours = a_partial_day_in_seconds/(60*60);
   DWORD a_partial_hour_in_seconds = a_partial_day_in_seconds%(60*60);
   DWORD a_partial_hour_in_minutes = a_partial_hour_in_seconds/60;
   DWORD a_partial_minute_in_seconds = a_partial_hour_in_seconds%60;
   
   DWORD years = days/365;
   DWORD months = (days%365)/30;
   DWORD a_partial_month_in_days = (days%365)%30;
   DWORD centuary = (years + 70) + 1900; 
   
   epoch_ty_instance.centuary = centuary;
   epoch_ty_instance.month = months;
   epoch_ty_instance.day = a_partial_month_in_days;
/*   
   printf("days = %u\n", days);
   printf("a_partial_day_in_hours = %u\n", a_partial_day_in_hours);
   printf("a_partial_hour_in_seconds = %u\n", a_partial_hour_in_seconds);
   printf("a_partial_hour_in_minutes = %u\n", a_partial_hour_in_minutes);
   printf("a_partial_minute_in_seconds = %u\n", a_partial_minute_in_seconds);
   
   printf("Years = %u\n", days);
   printf("months = %u\n", months);
   printf("a_partial_month_in_days = %u\n", a_partial_month_in_days);
   
   printf("centuary = %u\n", centuary);
*/   
   
   //printf("a_partial_day_in_hours = %u\n", a_partial_day_in_hours);

   return epoch_ty_instance; 
}